//
//  ByViewMineHeaderView.m
//  itboye_shop_ios
//
//  Created by justiOS on 17/2/15.
//  Copyright © 2017年 com.itboye. All rights reserved.
//

#import "ByViewMineHeaderView.h"

@implementation ByViewMineHeaderView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self) {
        self = [super initWithFrame:frame];
        self.backgroundColor = BY_THEME_COLOR;
        [self createViews];
    }
    return self;
}

- (void)createViews {
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    self.iconView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
    _iconView.center = CGPointMake(self.width/2 ,70);
    _iconView.image = [UIImage imageWithColor:[UIColor yellowColor]];
    _iconView.layer.cornerRadius = 25;
    _iconView.layer.masksToBounds = YES;
    _iconView.userInteractionEnabled = YES;
    [_iconView addGestureRecognizer:tap];
    [self addSubview:_iconView];
    
    CGFloat width = [BY_USER.nickname getSizeOfString:16].width + 20;
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH / 2 - width / 2, _iconView.bottom + 10, width, 20)];
    self.nameLabel.textColor = [UIColor whiteColor];
    _nameLabel.textAlignment = NSTextAlignmentCenter;
    _nameLabel.backgroundColor = [UIColor clearColor];
    _nameLabel.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    [_nameLabel addGestureRecognizer:tap2];
    [self addSubview:_nameLabel];
}

- (void)drawRect:(CGRect)rect {

}

- (void)tapAction:(UITapGestureRecognizer *)tap {
    if (self.tapBlock) {
        self.tapBlock();
    }

}


@end
